const {
    mysql,
    pool,
    router,
    Result,
    Myquery
} = require('../../connect');

// 获取所有的text数据
router.post('/delText', (req, res) => {
    delText(req, res)
})

// 插入数据
function delText(req, res) {
    // 取传过来的text参数
    var id = req.params.id || req.query.id || req.body.id;
    console.log(req.params, req.query, req.body, '参数')
    var sql = "DELETE from `node_one`";
    if (id) {
        // 根据id查找数据
        sql = "DELETE from `node_one` WHERE id = ?"
        var inserts = [id]
        sql = mysql.format(sql, inserts)
    }
    new Myquery(sql, (err, r) => {
        let code = 200,
            data = r,
            msg = '成功';
        if (err) {
            code = 500;
            msg = "失败";
            data = null
        }
        res.json(new Result({
            msg,
            data,
            code
        }))
    })
}

module.exports = router